package l1j.server.server.model;

import java.util.TimerTask;
import java.util.logging.Level;
import java.util.logging.Logger;
import l1j.server.server.model.Instance.L1PcInstance;
import l1j.server.server.serverpackets.S_SkillSound;//TODO MPR效果

public class MpRegenerationByDoll extends TimerTask {
	private static Logger _log = Logger.getLogger(MpRegenerationByDoll.class.getName());

	private final L1PcInstance _pc;

	public MpRegenerationByDoll(final L1PcInstance pc) {
		this._pc = pc;
	}

	// TODO 魔法娃娃DB化魔法娃娃額外追加的MPR
	private void regenMp() {
		final int mpr = this._pc.getDollList().getDollMprTime();
		if(mpr >0){
		final int newMp = Math.max(0, this._pc.getCurrentMp() + mpr);
	// TODO 魔法娃娃DB化魔法娃娃額外追加的MPR
		this._pc.sendPacketsX8(new S_SkillSound(this._pc.getId(), 6321));
		this._pc.setCurrentMp(newMp);
		}
	}

	@Override
	public void run() {
		try {
			if (this._pc.isDead()) {
				return;
			}
			this.regenMp();
		} catch (final Exception e) {
			_log.log(Level.WARNING, e.getLocalizedMessage(), e);
		}
	}
}